<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>图书管理系统 - 登录</title>
    <style>
        /* 页面整体样式 */
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        /* 登录容器样式 */
        .login-container {
            display: flex;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            width: 800px;
        }

        /* 左侧图片区域 */
        .login-image {
            flex: 1;
            background-color: #007bff;
            color: white;
            padding: 40px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .login-image h1 {
            font-size: 28px;
            margin-bottom: 20px;
        }

        .login-image p {
            font-size: 16px;
            text-align: center;
            line-height: 1.6;
        }

        /* 右侧登录表单区域 */
        .login-forms {
            flex: 1;
            padding: 40px;
        }

        .tab-buttons {
            display: flex;
            margin-bottom: 20px;
            border-bottom: 1px solid #ddd;
        }

        .tab-button {
            padding: 10px 20px;
            background-color: transparent;
            border: none;
            cursor: pointer;
            font-size: 16px;
            outline: none;
        }

        .tab-button.active {
            color: #007bff;
            border-bottom: 2px solid #007bff;
        }

        .form-container {
            display: none;
        }

        .form-container.active {
            display: block;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #333;
        }

        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            box-sizing: border-box;
        }

        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 10px;
        }

        .login-btn:hover {
            background-color: #0069d9;
        }

        /* 错误消息样式 */
        .error-message {
            color: #dc3545;
            margin-top: 10px;
            text-align: center;
            font-size: 14px;
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="login-image">
        <h1>图书管理系统</h1>
        <p>欢迎使用图书管理系统，请选择您的身份进行登录。</p>
    </div>
    <div class="login-forms">
        <div class="tab-buttons">
            <button class="tab-button active" onclick="showForm('student')">学生登录</button>
            <button class="tab-button" onclick="showForm('admin')">管理员登录</button>
        </div>

        <!-- 学生登录表单 -->
        <div id="student-form" class="form-container active">
            <form action="../common?method=login&type=student" method="post">
                <div class="form-group">
                    <label for="student-id">学号</label>
                    <input type="text" id="student-id" name="sno" placeholder="请输入学号" required>
                </div>
                <div class="form-group">
                    <label for="student-password">密码</label>
                    <input type="password" id="student-password" name="password" placeholder="请输入密码" required>
                </div>
                <button type="submit" class="login-btn">登录</button>
                <div class="error-message">${errorMsg}</div>
                <div style="text-align:center;margin-top:16px;">
                    没有账号？<a href="${pageContext.request.contextPath}/register.jsp">去注册</a>
                </div>
            </form>
        </div>

        <!-- 管理员登录表单 -->
        <div id="admin-form" class="form-container">
            <form action="../common?method=login&type=admin" method="post">
                <div class="form-group">
                    <label for="admin-username">用户名</label>
                    <input type="text" id="admin-username" name="username" placeholder="请输入用户名" required>
                </div>
                <div class="form-group">
                    <label for="admin-password">密码</label>
                    <input type="password" id="admin-password" name="password" placeholder="请输入密码" required>
                </div>
                <button type="submit" class="login-btn">登录</button>
                <div class="error-message">${errorMsg}</div>
            </form>
        </div>
    </div>
</div>

<script>
    function showForm(formType) {
        // 隐藏所有表单
        document.querySelectorAll('.form-container').forEach(form => {
            form.classList.remove('active');
        });

        // 取消所有标签页的激活状态
        document.querySelectorAll('.tab-button').forEach(tab => {
            tab.classList.remove('active');
        });

        // 显示选中的表单
        document.getElementById(formType + '-form').classList.add('active');

        // 激活对应的标签页
        event.target.classList.add('active');
    }
</script>
</body>
</html>